<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:decorate template="/templates/template.xhtml">
	<ui:define name="centro">
		<p:panel id="principal">
			<f:facet name="header">
					<h:outputText value="Manter Marca" />
				</f:facet>
			<h:form id="form1" prependId="false">
				<p:panel id="panelEdicao"
					rendered="#{manterMarcaMBean.editarState or manterMarcaMBean.adicionarState or manterMarcaMBean.detalharState}">

					<p:panelGrid columns="2" style="width:100%">
						<f:facet name="header">
							<h:outputText value="Cadastro de Marcas" />
						</f:facet>

						<h:outputText value="#{lbls.LBL_0005}:"
							rendered="#{manterMarcaMBean.editarState or manterMarcaMBean.detalharState}" />
						<h:outputText value="#{manterMarcaMBean.marca.id}"
							rendered="#{manterMarcaMBean.editarState or manterMarcaMBean.detalharState}" />

						<h:outputLabel for="txtMarcaNome" value="#{lbls.LBL_0010}:" />
						<h:panelGroup>
							<p:inputText value="#{manterMarcaMBean.marca.nome}"
								id="txtMarcaNome" label="#{lbls.LBL_0010}"
								rendered="#{manterMarcaMBean.editarState or manterMarcaMBean.adicionarState}" />
							<h:outputText value="#{manterMarcaMBean.marca.nome}"
								rendered="#{manterMarcaMBean.detalharState}" />
						</h:panelGroup>

						<f:facet name="footer">
							<p:commandButton value="#{lbls.LBL_0002}" process="panelEdicao"
								update=":principal" icon="ui-icon-check"
								rendered="#{manterMarcaMBean.editarState or manterMarcaMBean.adicionarState}"
								action="#{manterMarcaMBean.doSalvarAction}" />

							<p:commandButton value="#{lbls.LBL_0016}" process="panelEdicao"
								update=":principal" rendered="#{manterMarcaMBean.detalharState}"
								action="#{manterMarcaMBean.doEditarAction}" icon="ui-icon-check" />

							<p:commandButton value="#{lbls.LBL_0015}" process="@this"
								update=":principal" icon="ui-icon-cancel"
								action="#{manterMarcaMBean.doCancelarAction}" />
						</f:facet>
					</p:panelGrid>

				</p:panel>

				<p:panel id="panelPesquisa"
					rendered="#{manterMarcaMBean.pesquisarState}">
					<f:facet name="header">
						<h:outputText value="Cadastro de Marcas" />
					</f:facet>
					
					<div align="right">
						<p:commandButton value="#{lbls.LBL_0009}" id="btnAdicionar"
							icon="ui-icon-circle-plus" process="@this" update=":principal"
							action="#{manterMarcaMBean.doAdicionarAction}" />
					</div>

					<p:spacer height="10" />
					<p:dataTable id="marcaDataTable" var="marca" paginator="true"
						rows="5" emptyMessage="#{lbls.LBL_0004}"
						paginatorPosition="bottom" rowKey="#{marca.id}"
						value="#{manterMarcaMBean.listaMarcas}"
						paginatorAlwaysVisible="false"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
						<p:column style="width:10px;">
							<f:facet name="header">
								<h:outputText value="Código" />
							</f:facet>
							<div align="center">
								<h:outputText value="#{marca.id}" />
							</div>
						</p:column>

						<p:column>
							<f:facet name="header">
								<h:outputText value="Nome" />
							</f:facet>
							<h:outputText value="#{marca.nome}" />
						</p:column>

						<p:column style="width:40px">
							<p:commandButton id="selectButton"
								action="#{manterMarcaMBean.doDetalharAction}"
								icon="ui-icon-search" update=":principal" title="Visualizar">
								<f:setPropertyActionListener value="#{marca}"
									target="#{manterMarcaMBean.marca}" />
							</p:commandButton>
						</p:column>

						<p:column style="width:40px">
							<p:commandButton id="showDialogButton" icon="ui-icon-trash"
								onclick="confirmation.show()">
								<f:setPropertyActionListener value="#{marca}"
									target="#{manterMarcaMBean.marca}" />
							</p:commandButton>

						</p:column>

					</p:dataTable>


					<div align="right" style="margin-top: 10px;">
						<p:commandButton value="#{lbls.LBL_0009}" id="btnAdicionar2"
							icon="ui-icon-circle-plus" process="@this" update=":principal"
							action="#{manterMarcaMBean.doAdicionarAction}" />
					</div>

					<p:confirmDialog id="confirmDialog" message="#{msgs.MSG_0002}"
						header="#{msgs.MSG_0003}" severity="alert" appendToBody="true"
						widgetVar="confirmation">

						<p:commandButton value="#{lbls.LBL_0011}" process="@this"
							oncomplete="confirmation.hide()" update="marcaDataTable"
							action="#{manterMarcaMBean.doRemoverAction}" />

						<p:commandButton id="decline" value="#{lbls.LBL_0012}"
							onclick="confirmation.hide()" type="button" />
					</p:confirmDialog>

				</p:panel>
			</h:form>
		</p:panel>
	</ui:define>
</ui:decorate>
</html>